package com.pearadmin.pro.modules.statistics.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import com.pearadmin.pro.modules.exam.dto.ExamDTO;
import com.pearadmin.pro.modules.exam.dto.response.ExamOnlineRespDTO;
import com.pearadmin.pro.modules.examUtils.PagingReqDTO;
import com.pearadmin.pro.modules.experiment.service.ExperimentService;
import com.pearadmin.pro.modules.statistics.vo.StatisticsVO;
import com.pearadmin.pro.modules.sys.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = {"统计"})
@RestController
@RequestMapping(ControllerConstant.PREFIX_SYS + "stc")
public class StatisticsController extends BaseController {

    @Resource
    private SysLogService sysLogService;

    @Resource
    private ExperimentService experimentService;

    @ApiOperation(value = "登录折线图")
    @RequestMapping(value = "/loginChat", method = {RequestMethod.GET})
    public Result loginChat() {
        Map<String, Object> returnMap = new HashMap<>();
        // 登录人数
        int loginCount = sysLogService.loginChat("登录");
        // 注册用户
        int registerCount = sysLogService.loginChat("用户新增");
        // 虚仿访问人数
        int visitCount = experimentService.statistics();

        // 虚仿访问人数
        List<StatisticsVO> statisticsVOS = experimentService.statisticsSeparate();
        List<StatisticsVO> statisticsVOS_side = experimentService.statisticsVOS_side();

        returnMap.put("loginChat", loginCount);
        returnMap.put("registerCount", registerCount);
        returnMap.put("visitCount", visitCount);
        returnMap.put("trainingClass", "1200"); // 实训课时-- 暂无
        returnMap.put("statisticsVOS", statisticsVOS); // 项目点击数
        returnMap.put("statisticsVOS_side", statisticsVOS_side); // 项目点击数 右侧 0，7
        return success(returnMap);
    }


}
